package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.JzdxLegalInstrumentCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.JzdxLegalInstrumentResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.JzdxLegalInstrumentUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.JzdxLegalInstrumentEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface JzdxLegalInstrumentConvert {

    JzdxLegalInstrumentConvert INSTANCE = Mappers.getMapper(JzdxLegalInstrumentConvert.class);

    JzdxLegalInstrumentResultDTO convert(JzdxLegalInstrumentEntity s);

    JzdxLegalInstrumentEntity createTo(JzdxLegalInstrumentCreateDTO s);

    JzdxLegalInstrumentEntity update(JzdxLegalInstrumentUpdateDTO s);

    default JzdxLegalInstrumentEntity create(JzdxLegalInstrumentCreateDTO s, Long tenantId) {
        JzdxLegalInstrumentEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        return entity;
    }
}
